<?php

/**
 * Booking form base class.
 *
 * @method Booking getObject() Returns the current form's model object
 *
 * @package    playcafebookings
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBookingForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'booking_datetime'    => new sfWidgetFormInputText(),
      'subject_firstname'   => new sfWidgetFormInputText(),
      'subject_lastname'    => new sfWidgetFormInputText(),
      'subject_gender'      => new sfWidgetFormChoice(array('choices' => array('Male' => 'Male', 'Female' => 'Female'))),
      'subject_age'         => new sfWidgetFormInputText(),
      'contact_firstname'   => new sfWidgetFormInputText(),
      'contact_lastname'    => new sfWidgetFormInputText(),
      'contact_phone'       => new sfWidgetFormInputText(),
      'contact_email'       => new sfWidgetFormInputText(),
      'food_datetime'       => new sfWidgetFormInputText(),
      'guest_count'         => new sfWidgetFormInputText(),
      'party_type'          => new sfWidgetFormInputText(),
      'party_options'       => new sfWidgetFormTextarea(),
      'status'              => new sfWidgetFormChoice(array('choices' => array('Submitted' => 'Submitted', 'Confirmed' => 'Confirmed', 'Completed' => 'Completed'))),
      'amount_paid'         => new sfWidgetFormInputText(),
      'room'                => new sfWidgetFormInputText(),
      'guest_arrived_count' => new sfWidgetFormInputText(),
      'notes'               => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id'                  => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'booking_datetime'    => new sfValidatorPass(array('required' => false)),
      'subject_firstname'   => new sfValidatorString(array('max_length' => 64)),
      'subject_lastname'    => new sfValidatorString(array('max_length' => 64)),
      'subject_gender'      => new sfValidatorChoice(array('choices' => array(0 => 'Male', 1 => 'Female'), 'required' => false)),
      'subject_age'         => new sfValidatorInteger(array('required' => false)),
      'contact_firstname'   => new sfValidatorString(array('max_length' => 64)),
      'contact_lastname'    => new sfValidatorString(array('max_length' => 64)),
      'contact_phone'       => new sfValidatorString(array('max_length' => 16)),
      'contact_email'       => new sfValidatorString(array('max_length' => 64, 'required' => false)),
      'food_datetime'       => new sfValidatorPass(array('required' => false)),
      'guest_count'         => new sfValidatorInteger(array('required' => false)),
      'party_type'          => new sfValidatorString(array('max_length' => 64)),
      'party_options'       => new sfValidatorString(array('required' => false)),
      'status'              => new sfValidatorChoice(array('choices' => array(0 => 'Submitted', 1 => 'Confirmed', 2 => 'Completed'), 'required' => false)),
      'amount_paid'         => new sfValidatorInteger(array('required' => false)),
      'room'                => new sfValidatorString(array('max_length' => 64, 'required' => false)),
      'guest_arrived_count' => new sfValidatorInteger(array('required' => false)),
      'notes'               => new sfValidatorString(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Booking', 'column' => array('id')))
    );

    $this->widgetSchema->setNameFormat('booking[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Booking';
  }

}
